package com.gxl.design.builderpattern.builder;

import com.gxl.design.builderpattern.GoodsInterface;

import java.util.ArrayList;
import java.util.List;

public class Order {

    private List<GoodsInterface> goodss = new ArrayList<>();

    public void addGoods(GoodsInterface goods){
        goodss.add(goods);
    }

    public Integer getSumOfPrice(){
        Integer sumOfPrice = 0;
        for (GoodsInterface goods : goodss){
            sumOfPrice = sumOfPrice + goods.goodsPrice();
        }
        return sumOfPrice;
    }

    public void printGoodsList(){
        for (GoodsInterface goods : goodss){
            System.out.println(goods.goodsName() + " : " + goods.goodsPrice() + " 元.");
        }
    }
}
